<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.cndatacom.ccsinfoMgr.model.*"%> 
<%@ page import="com.cndatacom.eweb.ckeditor.CKPaginationSupport"%>

<% 
	String ctx = request.getContextPath();
	String content = ((BulletinInfo)request.getAttribute("bulletinInfo")).getContent();
	String paging = request.getParameter("paging");
	
	String[] contentArray = CKPaginationSupport.seperateContentToPages(content);
	int pageCount = contentArray.length;
	int currPage = 1;
	if(request.getParameter("currPage") != null) {
		currPage = Integer.parseInt(request.getParameter("currPage"));
	}
	
	String attachment = "";//附件相对路径
	String attachName = "";//附件名称
	if(((BulletinInfo)request.getAttribute("bulletinInfo")).getAttachment() != null) {
		attachment = ((BulletinInfo)request.getAttribute("bulletinInfo")).getAttachment();
		attachName = attachment.substring((attachment.lastIndexOf("/")+1));
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>详细内容</title>
<link rel="stylesheet" type="text/css" href="<%=ctx%>/infoMgr/css/article.css"/>
<script src="<%=ctx%>/js/submitFunctions.js" type="text/javascript"></script>
</head>

<body>
<form name="downloadForm" action="download.action" method="post">
	<input type="hidden" name="filePaht" id="filepath"/>
	<input type="hidden" name="fileName" id="filename"/>
</form>
<div class="new_article">
	<h1>${bulletinInfo.title}</h1>
	<h6>2011-04-11 09:59:29　来源: 新华网(广州)</h6>
       <%
    	if(paging.equals("1")) {
    %>           
	<%=contentArray[currPage-1] %>
	<%
		if(pageCount > 1) {
	%>
		<a href="javascript:prePage()">上一页</a>
			
	<%
		for(int i=1; i<=pageCount; i++) {
	%>	
			<a href="javascript:gotoPage(<%=i%>)"><%=i%></a>
	<%
		}
	%>
		<a href="javascript:nextPage()">下一页</a> <a href="javascript:showAllContent()">全文</a>
	<%
			}
		}else {
	%>
			<%=content%>
	<%
		}
	%>
	<br/>
	
	<%
		if(!attachment.equals("")) {
	%>
			附件： <a href="#" onclick="downloadFile('<%=attachment%>','<%=attachName%>');return false;"><%=attachName%></a>
	<%
		}
	%>

</div>
</body>
</html>

<script>

	//分页的实现
	function prePage() {
		var currpage = <%=currPage%>;
		if(currpage > 1) {
			gotoPage(currpage-1);
		}
	}
	
	function nextPage() {
		var currpage = <%=currPage%>;
		var pagecount = <%=pageCount%>;
		if(currpage < pagecount) {
			gotoPage(currpage+1);
		}
	}
	
	function showAllContent() {
		var local = window.location.href;
		var temp = local.indexOf("&paging=");
		if(temp > 0) {
			local = local.substring(0,temp+8)+"0";
			window.location.href = local;
		}
	}
	function firstPage() {
		
	}
	
	function lastPage() {
		
	}
	
	//跳页
	function gotoPage(pageNum) {
		var local = window.location.href;
		var temp = local.indexOf("&currPage=");
		if(temp > 0) {
			local = local.substring(0,temp+10)+pageNum;
		}else {
			local = local+"&currPage="+pageNum;
		}
		window.location.href = local;
	}
</script>